/**
 * Created With IntelliJ IDEA
 * Description:牛客网：NC228 判断子序列
 *<a href="https://www.nowcoder.com/practice/39be6c2d0a9b4c30a7b04053d5960a84?tpId=117&tqId=39453&ru=/exam/oj">...</a>
 * User: DELL
 * Data: 2023-02-11
 * Time: 22:10
 */
public class Solution {
    public boolean isSubsequence (String S, String T) {
        int len1 = S.length();
        int len2 = T.length();
        int i = 0;
        int j = 0;
        while (i < len1 && j < len2) {
            if (S.charAt(i) == T.charAt(j)) {
                i++;
                j++;
            } else {
                j++;
            }
        }
        return len1 == i;
    }
}
